//
//  TTCoreCommon.h
//  Tint
//
//  Created by Kevin Wu on 8/22/12.
//  Copyright (c) 2012 Telligenty. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

/**
 * SDK definitions useful in availability checks for conditionally compiling code.
 *
 * Example:
 *
 *     #if __IPHONE_OS_VERSION_MAX_ALLOWED >= TTIOS_3_2
 *       // This code will only compile on versions >= iOS 3.2
 *     #endif
 *
 * These macros are defined unconditionally and separately from the __IPHONE_* macros
 * because there might be methods that use the #ifdef state of one of the __IPHONE_ macros
 * to conditionally compile their code (however incorrect this may be).
 */
#define TTIOS_2_0 __IPHONE_2_0
#define TTIOS_2_1 __IPHONE_2_1
#define TTIOS_2_2 __IPHONE_2_2
#define TTIOS_3_0 __IPHONE_3_0
#define TTIOS_3_1 __IPHONE_3_1
#define TTIOS_3_2 __IPHONE_3_2
#define TTIOS_4_0 __IPHONE_4_0
#define TTIOS_4_1 __IPHONE_4_1
#define TTIOS_4_2 __IPHONE_4_2
#define TTIOS_4_3 __IPHONE_4_3
#define TTIOS_5_0 __IPHONE_5_0

/*
 * Compatibility
 */
typedef enum {
    TTDeviceModelIphone         = 0x000000FF,   // iPhone 1, iPhone 2, iPhone 3.
    TTDeviceModelIphoneRetina   = 1 << 0,       // iPhone 4, iPhone 4S.
    TTDeviceModelIphone4Inch    = 1 << 1,       // iPhone 5.
    
    TTDeviceModelIpod           = 0x0000FF00,   // iPod 1, iPod 2, iPod 3.
    TTDeviceModelIpodRetina     = 1 << 8,       // iPod 4.
    TTDeviceModelIpod4Inch      = 1 << 9,       // iPod 5.
    
    TTDeviceModelIpad           = 0x00FF0000,   // iPad 1, iPad 2.
    TTDeviceModelIpadRetina     = 1 << 16,      // The new iPad, iPad 4.
    TTDeviceModelIpadMini       = 1 << 17,      // iPad mini.
} TTDeviceModel;

TTDeviceModel TTCurrentDeviceModel();
CGFloat TTCurrentOSVersion();

/*
 * Paths
 */
NSString *TTDocumentsPath();
NSString *TTLibraryPath();
NSString *TTCachesPath();

/*
 * Image cache
 */
UIImage *TTCachedImage(NSString *name);
UIImage *TTUncachedImage(NSString *name);
UIImage *TTCreateUncachedImage(NSString *name);


/*
 * Validity
 */
BOOL TTIsInstance(id object, Class cls);
BOOL TTIsStringWithText(id object);
BOOL TTIsDataWithBytes(id object);
BOOL TTIsArrayWithItems(id object);
BOOL TTIsDictionaryWithItems(id object);
BOOL TTIsSetWithItems(id object);

/*
 * RFC 3339 date
 */
NSDateFormatter *TTRFC3339DateFormatter();
NSDate *TTDateFromRFC3339DateString(NSString *string);
NSString *TTRFC3339DateStringFromDate(NSDate *date);

/*
 * Non-retaining collections
 */
NSMutableArray *TTCreateNonRetainingMutableArray();
NSMutableDictionary *TTCreateNonRetainingMutableDictionary();
NSMutableSet *TTCreateNonRetainingMutableSet();

